package com.ln.lnzw.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.blankj.utilcode.util.ScreenUtils;
import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.ln.lnzw.R;
import com.ln.lnzw.bean.ServiceTopRecomBean;

import java.util.List;

/**
 * 作者 : wlt
 * 创建时间:  2018-04-24
 * QQ : 1346947404
 * 邮箱:wanglt_android@163.com
 * 类说明:便民服务首页为你推荐的适配器
 * In me the tiger sniffs the rose
 */

public class RecomToYouAdapter extends BaseQuickAdapter<ServiceTopRecomBean,BaseViewHolder>{
    private ImageView mImageView;
    public RecomToYouAdapter(int layoutResId, @Nullable List<ServiceTopRecomBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ServiceTopRecomBean item) {
        mImageView = helper.getView(R.id.imageView);
        ViewGroup.LayoutParams layoutParams = mImageView.getLayoutParams();
        layoutParams.width= ScreenUtils.getScreenWidth()/3+(ScreenUtils.getScreenWidth()/3)/3-40;
        layoutParams.height=layoutParams.width/2-20;
        mImageView.setLayoutParams(layoutParams);
        mImageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        Glide.with(mContext).load(item.getTopimg()).placeholder(R.mipmap.icon_fwzwt01).error(R.mipmap.icon_fwzwt01).into(mImageView);
        mImageView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //TODO 点击进入详情
            }
        });
    }
}
